package exercises.leetcode;

/**
 * <a href="">
 * </a>
 *
 * <p><span color="#87CEEB">描述:</span>
 *
 * @author or2
 * @date 2021年11月13日 时间: 22:30
 */
public class No5910 {
    public boolean checkAlmostEquivalent(String word1, String word2) {
        var freq = new byte[26];
        for (int i = 0, len = word1.length(); i < len; i++) {
            freq[word1.charAt(i) - 'a']++;
        }
        for (int i = 0, len = word2.length(); i < len; i++) {
            freq[word2.charAt(i) - 'a']--;
        }
        for (var c : freq) {
            if (Math.abs(c) > 3) return false;
        }
        return true;
    }
}
